const vm = require('vm');

const sandbox={
	exports: {}
};
vm.createContext(sandbox); // Contextify the sandbox.

const code = 'exports.name  = "zfpx"';
// x and y are global variables in the sandboxed environment.
// Initially, x has the value 2 because that is the value of sandbox.x.
vm.runInContext(code, sandbox);

console.log(sandbox.exports); 